Repository navigation
Provider: serve Qwen4-35B-A3B on native Qwen4 stack (replay provider-integ + SDK main 64a6f34f) - #2949
Draft
GumbiiDigital wants to merge 29 commits into
Draft
Provider: serve Qwen4-35B-A3B on native Qwen4 stack (replay provider-integ + SDK main 64a6f34f)#2949GumbiiDigital wants to merge 29 commits into
GumbiiDigital wants to merge 29 commits into
Conversation
Qwen4-35B-A3B declares qwen4_moe / qwen4_moe_text. The native engine, embedded MTP, prefix-cache load hash, reasoning, stream guards and tool format checks now take those types as they take qwen4_exp. Identity-gated features (media, the native tool constraint, effort templates) still key on qualified registry IDs. Pins the SDK branch that adds the types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qwen4ModelIdentity names two builds: Flash-Next (qwen4_exp) and Qwen4-35B-A3B (qwen4_moe), whose IDs are qwen4-35b-a3b, the served artifact EigenLabs/Qwen4-35B-A3B-MLX-4bit-mtp and the upstream alias mlx-community/Qwen4-35B-A3B-oQ4e-mtp. The A3B IDs take the native Qwen4 listing, automatic paged KV and SSD prefix checkpoints; their listing quotes the native 1,048,576-token window. Media is served for each build only with its own exact geometry (A3B: text 2,048 x 40, qwen4_moe_vision tower 27 x 1,152, out 2,048). Native tool framing and inner-reasoning handling require a qualified ID with its build's own type, and the media path passes the loaded wrapper's real type. Omitted sampling knobs take the A3B checkpoint's generation_config.json. Flash-Next's Qwen 3.8 effort template stays with Flash-Next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qwen4-35B-A3B's template takes xhigh, high (its default), low and off, and raises for any other effort, for off with thinking on and for any other effort with thinking off. For qwen4_moe and qwen4_moe_text every client effort now renders one of them: none, minimal and low render low, medium and high render high, xhigh and max render xhigh while thinking, and a thinking switch off (none, off, 0 or enable_thinking false) renders off. The effort vectors add both types, a family for them and the set qwen4_moe_template_model_types (516 cases). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qwen publishes the model's tokenizer and chat encoder as remote Python code; the served artifact carries Qwen's tokenizer-compat tokenizer.json and chat_template.jinja at its root. For qwen4_moe types the loader reads the remote-code class name Qwen4Tokenizer as the byte-level BPE model tokenizer.json holds, in memory; a snapshot without the two files is skipped at discovery and refused at load with a clear error instead of rendering without them. Every prompt of the family renders tool declarations and arguments as the trained encoder writes them: Transformers' tojson (members in the order sent, ", " and ": " separators, no escaping) and the caller's JSON, with tool-call arguments parsed from their JSON strings in order. A fixture pins the served template (the upstream compat template with the loop variable call, which swift-jinja reserves, renamed) and checks that it renders the reference encoder's strings through the prompt pipeline: every effort, both thinking switches, earlier reasoning, tool calls, reordered tool results, media placeholders and five encoder golden cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK keeps Qwen4-35B-A3B's n-gram table resident by default and Flash-Next's on SSD; DARKBLOOM_QWEN4_PLE_SSD_OFFLOAD chooses one for every Qwen4 model. The LaunchAgent now forwards it. [backend] qwen4_ngram_residency_by_model (model ID to memory or ssd) is projected into that switch before models are scanned, so a model's quote and its load agree. A map one switch value cannot honour, unknown IDs and unknown values are logged and leave the defaults; an operator's value wins. A projected value is marked and never written into the service plist. Memory quotes follow the residency the SDK loads each type with: in memory, every weight with the ordinary allowance and no offload credit; on SSD, the resident weights plus the native loading allowance with the offloaded bytes reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A support reference for Qwen4-35B-A3B (identity, efforts, compat tokenizer and template, media gate, n-gram residency and memory quotes), the residency controls in the configuration and CLI references, the memory quotes in the hardware requirements, and a changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A qwen4-35b-a3b clip was sampled with the checkpoint's own settings: 2 fps, up to 768 frames and 25,165,824 clip pixels (12,288 visual tokens) per clip. Its IDs now take the Qwen 3.5-family caps (32 frames a clip, 4,096 visual tokens shared by a request's clips), which the SDK's Qwen4ExpProcessor reads from processing.video (an SDK without that keeps ignoring them). DARKBLOOM_QWEN_VIDEO_MAX_FRAMES / _MAX_TOKENS tune them; DARKBLOOM_QWEN4_VIDEO_BUDGET=0 keeps the checkpoint's sampling, and the LaunchAgent forwards it. Flash-Next and other models are unchanged. Tests: Qwen4MoEVideoBudgetTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves libs/mlx-swift-lm from qwen4-a3b/support (1fbe8a49) to qwen4-a3b/qual (688ec3dc): qwen4-a3b/integration (A3B kernels, decode fusions, n-gram memory/SSD residency with the GPU gather) plus the native Qwen4ChatEncoder, the reserved-token mask in the qwen4_moe heads and Qwen4ExpProcessor's video caps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK now resolves a Qwen4 model's n-gram residency from DARKBLOOM_QWEN4_PLE_RESIDENCY (memory or ssd) before DARKBLOOM_QWEN4_PLE_SSD_OFFLOAD. Both footprints already quote through that resolution (useMmap(forModelType:)), but Qwen4NgramResidency only knew the legacy switch: an operator's named switch did not count as an override of qwen4_ngram_residency_by_model, and the LaunchAgent did not forward it. It is now both. A loaded native Qwen4 model logs the residency it reports (Qwen4ExpPLEResidencyReporting) beside the one its memory was quoted for, with a warning when they differ. Tests: Qwen4NgramResidencyTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qwen4-35B-A3B's own tokenizer renders a conversation as segments and tokenizes each alone (encoding_qwen4.py): scaffolding recognises special tokens, message data never does. The compat template rendered once and tokenized once merges across segment boundaries (about 30% of tool conversations get other IDs) and turns special-token text in messages into control tokens. With DARKBLOOM_QWEN4_NATIVE_ENCODER=1 (read once per process, off by default) the tokenizer bridge of a qwen4_moe model renders every prompt with the SDK's Qwen4ChatEncoder: messages, tools and earlier calls' arguments from the same template inputs (ordered Jinja values keep the request's member order), reasoning_effort / enable_thinking / preserve_thinking from the template context, scaffolding tokenized by the served tokenizer and data by a second instance of the same tokenizer.json without added tokens. Media requests reach it through the SDK processor, whose placeholders it renders. The prompt token cache is off for that model while it is on. The LaunchAgent forwards the switch. Tests: Qwen4NativeChatEncodingTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The media gate reserved a flat 1,024 KV tokens per image (MediaIngest.visionTokensPerImage). A native Qwen4 checkpoint resizes each image within its own bounds: a Qwen4-35B-A3B image renders up to 16,384 visual tokens (3000x2000 rendered 5,828 on sd2), so 16 large images could hold ~262K tokens of KV against 16K reserved. For a qwen4_* model the gate now prices each inline image from its header size through the loaded processor's exact resize (Qwen4ExpProcessor.imageVisualTokens), plus its two vision delimiters, and keeps the rest of the projection (text, videos, output, context clamp). A request with an image whose size can't be read keeps the flat charge; DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION=0 keeps it for every request (forwarded by the LaunchAgent). Admission only: prompts and outputs are unchanged. Tests: Qwen4ImageReservationTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itches The Qwen4-35B-A3B reference now states the video caps it takes, the per-image KV reservation, the opt-in native encoder, the reserved-token mask in the SDK heads and the SDK's named n-gram residency switch; configuration.md lists DARKBLOOM_QWEN4_PLE_RESIDENCY, DARKBLOOM_QWEN4_VIDEO_BUDGET, DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION, DARKBLOOM_QWEN4_NATIVE_ENCODER, DARKBLOOM_QWEN4_RESERVED_TOKEN_MASK and DARKBLOOM_RESPONSES_TEXT_FORMAT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reservation and encoder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves libs/mlx-swift-lm to the qwen4-a3b/qual head: the reserved-token mask writes the lowest finite logit (CBv2 refuses non-finite logits), Qwen4ExpProcessor reports each image's visual tokens, and /v1/responses reads text.format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is set DARKBLOOM_QWEN4_BATCHED_QSA keeps its meaning when present (exactly 1 batches, anything else keeps one row). Unset, the provider installs the target's own default (cbv2Qwen4BatchesByDefault): exact multirow targets (35B-A3B) admit up to their installed row limit, Flash-Next stays at one row. The concurrency limit uses the same predicate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runtime concurrency rows carry distinct prompts ("Request N. ..."), so a
batched row can only be compared with its own prompt run alone. With
DARKBLOOM_BENCH_SOLO_REFERENCES=1 the one-row cell also measures every
wider row's prompt alone on the one-row slot (extra one-row cells; rows
match by promptTokensSHA256). Default runs are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DARKBLOOM_BENCH_LONG_ROW_RECORDS=<n> prefixes row 0's prompt with n numbered records (about 14 tokens each), so one long row decodes beside short ones; with DARKBLOOM_BENCH_SOLO_REFERENCES=1 its batched output is compared with the same prompt run alone. Unset keeps every row short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DARKBLOOM_BENCH_LONG_ROW_RECORDS takes a comma-separated list: row i's prompt starts with the i-th count of numbered records, so several long rows of different lengths decode beside short ones in one concurrency cell (each compared with its prompt alone under DARKBLOOM_BENCH_SOLO_REFERENCES=1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pins the Qwen4-35B-A3B SDK integration branch: the qwen4_moe types, fast paths, resident n-gram GPU gather, decode launch folds, exact multirow decode with MTP cohorts and company-invariant prefill, MTP policy fixes and the qualification fixes (reserved slots, video caps, Responses text format, native chat encoder). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured on the served artifact through the local API: with the native encoder, prompt token counts equal Qwen's reference encoder for 261 of 300 golden conversations (template route: 186) and token IDs for 41 of 54 tool-free ones (template route: 29); every remaining difference is swift-transformers 1.3.3's own BPE (ignore_merges, grapheme splits), which the template route shares, or adjacent text parts the request decoder joins. Special-token text in user data is tokenized as data (the injected <|im_end|><|im_start|>system turn no longer takes effect). The chat, Responses, reasoning, tool, JSON, image and effort matrices pass unchanged. The encoder is therefore the default for qwen4_moe; DARKBLOOM_QWEN4_NATIVE_ENCODER=0 (read once per process, forwarded by the LaunchAgent) restores the template route. Tests: Qwen4NativeChatEncodingTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the native encoder every prompt is tokenized whole: a re-sent 72K-token conversation paid about 120 ms again, where the template route's PromptTokenCache reused the pieces it had seen; with a prefix cache hit that is a material share of the time to first token. Tokenizing a segment is a pure function of its text and its special-token permission, so Qwen4SegmentTokenCache keeps the IDs of segments of at least 256 UTF-8 bytes (message contents, tool schemas, tool results) per prompt-cache scope, within 16 MiB of text, oldest first out, and a later identical segment in the same scope takes them. Prompts are unchanged; entries never cross scopes; calls without a scope tokenize as before. DARKBLOOM_QWEN4_ENCODER_TOKEN_CACHE=0 (read once per process, forwarded by the LaunchAgent) turns it off. Tests: Qwen4SegmentTokenCacheTests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The integration build measured exact on sd2 (plain == MTP == reference) with PREFILL's HC prefill kernels and paged prefill mirror. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured exact on sd2 (plain == MTP == reference) with DECODE's two-launch HC, MoE and QSA kernels, MTP's draft prefix and BATCH's multirow verify fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An installed service sees only the environment its plist carries, and none of the SDK's native Qwen4 kill switches was on the passthrough list, so a service could not throw them. Qwen4KillSwitches lists the reviewed ones: the multirow, MTP, decode, verify, prefill, n-gram table and logits switches whose 0 restores the earlier path, the five per-model MTP defaults and DARKBLOOM_QWEN4_BATCHED_QSA. LaunchAgent.passthroughEnvironment forwards each only at a restoring value (exactly 0 where the SDK compares the raw value, else 0/false/no/off). Diagnostics such as the MTP round log, non-exact opt-ins such as tensor-unit QSA, tuning knobs and values that turn a path on are never forwarded. Any DARKBLOOM_QWEN4_* or DARKBLOOM_CBV2_* key used to drop reviewed serving profiles, even at its default. A listed kernel or fusion switch at its restoring value or default now keeps them; the switches that change how many rows batch, speculate or share a prefill step (BATCHED_QSA, MULTIROW, COMPANY_INVARIANT_PREFILL, MTP_COHORTS, MTP_ROW_WIDTHS) and every other key still drop them. Tests: Qwen4KillSwitchesTests (the reviewed list, forwarding only restoring values, profile retention by switch kind) and qwen4KernelKillSwitchesKeepTheReviewedProfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The configuration reference lists the forwarded Qwen4 kill switches with their restoring values, which change capacity and which are read only by SDK integrations newer than the provider's pin; the qualification guide and the inference architecture note which ones keep reviewed serving profiles. Changelog fragment included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Carries the exact Qwen4 GDN conv (precise sigmoid), BATCH's multirow and cohort routes, and MTP's depth policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h list Thirteen switches the SDK integration and its prefill lane added since the list was written join Qwen4KillSwitches.all (74 in all): - kernel and fusion switches, forwarded at 0 (or false/no/off) and keeping reviewed serving profiles: MULTIROW_GDN_STEP, MULTIROW_MOE_FOLDS, MULTIROW_QSA_FOLDS, MULTIROW_QMV_GROUPED, INDEX_ROW_BATCH, GDN_PACKED and HC_WIDE_SPLIT (exactly 0); - capacity switches, forwarded at their restoring value but still dropping reviewed profiles: WIDE_PREFILL (prompt step width) and the cohort draft policy MTP_CHAINED_BASELINE and CBV2_MTP_CHAINED_PROBE; - three whose new behaviour removed a rule, so 1 (or true/yes/on) restores it and is the only value forwarded: MTP_D3_BUMP, MTP_COPY_ROUNDS_AS_SAMPLES and DARKBLOOM_QWEN_GDN_FROZEN_TREE_WALK (Restore.onWord). Tests: Qwen4KillSwitchesTests (the list, forwarding by restoring value for each restore kind, profile retention by switch kind) and qwen4KernelKillSwitchesKeepTheReviewedProfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-Labs#586) and align docs/changelog
|
@GumbiiDigital is attempting to deploy a commit to the EigenLabs Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds full provider-side serving support for Qwen4-35B-A3B (
qwen4_moe/qwen4_moe_text) on the native Qwen4 stack (alongside Flash-Nextqwen4_exp), pinned to landed SDKmain64a6f34feffd1137f33eaaf56e6040bf296e8883:libs/mlx-swift-lm→64a6f34feffd1137f33eaaf56e6040bf296e8883): Advanceslibs/mlx-swift-lmfromdev's70183a70ontoLayr-Labs/mlx-swift-lmmaincovering Muse Glimmer#579, Qwen4-35B-A3B integration +mtp-mirror-fix(#584), and the 17 multi-row batching commits (#586/#585: paged multi-row vector-SDPA, rows-adjacent MoE/QSA folds, non-concatenated FP32 GDN row states, MTP cohort acceptance break-even gating, multi-row router GEMV).provider-swift/Package.swiftuses.package(path: "../libs/mlx-swift-lm", traits: [])andPackage.resolvedrequired no changes.Qwen4ModelIdentity,Qwen4SupportPolicy,EngineV2SamplingDefaults): Qualifiesqwen4-35b-a3b,EigenLabs/Qwen4-35B-A3B-MLX-4bit-mtp, and aliasmlx-community/Qwen4-35B-A3B-oQ4e-mtpfor automatic paged KV, complete SSD prefix checkpoints, embedded 1-layer MTP with exact acceptance, continuous batching, native1_048_576context window, and checkpoint sampling defaults (temperature=1.0,top_p=0.95,top_k=20, no presence penalty).DARKBLOOM_QWEN4_PLE_RESIDENCYdefaults to.memoryforqwen4_moe*(35,215,477,491 B weights, 39.36 GiB scanner quote, no offload credit), coordinating with catalogmin_ram_gb = 64indarkbloom-platform. Opt-in SSD offload remains available viaDARKBLOOM_QWEN4_PLE_RESIDENCY=ssd,DARKBLOOM_QWEN4_PLE_SSD_OFFLOAD=1, or[backend] qwen4_ngram_residency_by_model(22.42 GB resident + 6.21 GB transient = 26.66 GiB quote, 12.80 GB offloaded).max_output_length = 32768(IntegrationModels.defaultOutputCap = 32_768anddarkbloom-platformcatalog template).0.10.23(ProviderCore.versionstays0.10.22ondevperdocs/operations/provider-release.md; bumped on release cut).Qwen4NativeChatEncoding,Qwen4SegmentTokenCache,Qwen4CompatTokenizer): Routesqwen4_moeprompts through SDKQwen4ChatEncoderby default (DARKBLOOM_QWEN4_NATIVE_ENCODER=0restores compatchat_template.jinja) with per-scope repeated-segment token caching (DARKBLOOM_QWEN4_ENCODER_TOKEN_CACHE=0disables). Fails closed at discovery and load if compattokenizer.json/chat_template.jinjaare absent; mapsQwen4Tokenizerin memory.ReasoningEffort,fixtures/prompt-contract/v1/reasoning_effort_vectors.json): Mapsnone/off/0/enable_thinking: false→off,minimal/low→low,medium/high→high(default),xhigh/max→xhigh; expands contract vectors to 516 reproducible cases.ToolChoicePromptPolicy,ModelMediaPolicy,Qwen4ImageReservation,MediaIngest+VideoBudget): Qwen XML format (ToolCallFormat.qwen35), sampler-enforcedQwen4NativeToolConstraintforrequired/ named choices on qualified text requests, caller-order JSON tool declarations/arguments, pinnedqwen4_moe_visiongeometry gate, up to 16 images with per-image visual-token KV reservation (DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION=0restores flat 1,024), and Qwen 3.5-family video caps (32 frames/clip, 4,096 visual tokens;DARKBLOOM_QWEN4_VIDEO_BUDGET=0restores checkpoint sampling).Qwen4KillSwitches,LaunchAgent,ServingPerformanceProfile): Forwards the 74 reviewed native Qwen4 SDK kill switches tolaunchdonly at their restoring values (never diagnostics, experimental opt-ins, or inexact flags); preserves reviewed serving profiles for kernel/fusion/depth switches while dropping them for capacity-changing switches.Omitted / Deferred Items
ProviderCore.versionbump to0.10.23devholds0.10.22until the dedicated release PR intomaster(docs/operations/provider-release.md).swift-transformers1.4.0 upgradeQwen4ChatEncodermatches 678/678 text/segment goldens and 568/672 token IDs onswift-transformers1.3.3 (672/672on 1.4.0).json_mode/structured_outputsdarkbloom-platformActivation PR &provider-contracts.py snapshot0.10.23cut"") until0.10.23ships.Placeholders / Pending Rollout Items
2026-12-04-r2(M4 Max + M5 Max/Ultra, resident 64 GB+ and SSD 48 GB)v0.10.23(dev→master, signed/notarized)darkbloom-platformActivation PR (qwen4MoeRegistryMinimumProviderVersion = "0.10.23"+provider-contracts.py snapshot)Blast Radius / What This Could Affect
Shared Seams & Coexistence Audit (
devPRs#2925–#2933)Every overlapping file between
origin/dev(08ef86a5cb) andorigin/qwen4-a3b/provider-integ(e9493a61d2) was audited for textual and semantic coexistence:devPRs (#2925–#2933)provider-swift/Sources/ProviderCore/Inference/Prompting/ToolChoicePromptPolicy.swiftQwen4SupportPolicy.isOwnedModelID(...) && modelType == "qwen4_exp"withQwen4ModelIdentity.isQualified(request.model, nativeModelType: modelType)innativeFramingHandlesChoice.#2912(settlesGemmaFrameAtLimit). Audited against#2926/#2928(ToolArgumentNulls: unset default stays Qwen 3.6 + Qwen 3.5 35B only) and#2933(TypelessNullToolSchemas: opt-in via=1, orthogonal to Qwen4 native framing).model_type(qwen4_exporqwen4_moe) on text-only requests.provider-swift/Sources/ProviderCore/Service/LaunchAgent.swiftDARKBLOOM_QWEN4_PLE_SSD_OFFLOAD,DARKBLOOM_QWEN4_PLE_RESIDENCY,DARKBLOOM_QWEN4_VIDEO_BUDGET,DARKBLOOM_QWEN4_NATIVE_ENCODER,DARKBLOOM_QWEN4_ENCODER_TOKEN_CACHE,DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION, stripsprovider.toml-projected residency, and mergesQwen4KillSwitches.passthrough(from:).#2912(GemmaAutoCallCheck.frameAtLimitKey),#2925(Gemma 4 M5 Ultra defaults),#2926(ToolArgumentNullsdoc comment), and#2933(TypelessNullToolSchemas.environmentKey).Qwen4KillSwitches.passthroughforwards strictly restoring values, never diagnostics or inexact opt-ins; never writesprovider.toml-projected residency to plist.provider-swift/Sources/ProviderCore/Inference/Engine/Scheduler/MultiModelBatchSchedulerEngine.swiftQwen4ImageReservation.kvTokens(...)on non-GLM native Qwen4 media requests (Qwen4SupportPolicy.isQwen4ModelType(modelType)).#2912(settledGemmaCallsAtLimitat line 2615).!glmMedia && Qwen4SupportPolicy.isQwen4ModelType(modelType);DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION=0restores flat 1,024 charge.docs/developer/test.mdreasoning_effort_vectors.jsoncase count (446→516).#2929's new## Contribution Rulessection (same2026-12-04freshness header, disjoint body hunks). Verified withmake docs-check(0 findings).docs/architecture/inference.md&docs/reference/configuration.mdqwen4_moe/qwen4_moe_textarchitecture, native encoder, image reservation, video caps, n-gram residency, and 74 service-forwarded kill switches.#2925–#2933doc updates; updated stalenewer than aa6e3672notes for switches now landed in64a6f34f.libs/mlx-swift-lm70183a70→64a6f34f(#579+#584+#586).mainincluding Muse Glimmer#579and Qwen4#584/#586.QSA_NAX,QSA_INDEXER_NAX,GDN_PIPELINED) unless compiled with-DDARKBLOOM_QWEN4_ALLOW_INEXACT.Non-Interference Guarantees
qwen4_exp): Keeps.ssdPLE default,262_144native context, its ownQwen4NativeVisionGeometry, Qwen 3.8 reasoning effort mapping, and existing kernels/outputs.DARKBLOOM_TOOL_ARGUMENT_NULLSdefault behavior (#2903,#2926,#2928), independent effort tables, and GDN/MTP defaults (DARKBLOOM_QWEN_GDN_FROZEN_TREE_WALK=1kill switch available if needed).#2925) andGemmaAutoCallCheckframe-at-limit behavior (#2912) untouched.ModelMediaPolicy,ReasoningEffort, andEngineV2KVBackendPolicybranch on exact model ID /model_type.Rollback / Fail-Closed Profile
LaunchAgent:DARKBLOOM_QWEN4_NATIVE_ENCODER=0,DARKBLOOM_QWEN4_ENCODER_TOKEN_CACHE=0,DARKBLOOM_QWEN4_IMAGE_GEOMETRY_RESERVATION=0,DARKBLOOM_QWEN4_VIDEO_BUDGET=0,DARKBLOOM_QWEN4_PLE_RESIDENCY=ssd(orDARKBLOOM_QWEN4_PLE_SSD_OFFLOAD=1), plus all 74 SDK kill switches inQwen4KillSwitches.all.tokenizer.json/chat_template.jinjafails closed at discovery and load (Qwen4CompatTokenizer.Failure.missingCompatFiles).darkbloom-platform's unset version floor ("") andregister.template.jsonplaceholders (prices: null,promote: false).Before and After
Behavior
flowchart LR subgraph Before["Before (dev @ 08ef86a5)"] B1[qwen4-35b-a3b request] --> B2[Unqualified model ID / SDK @ 70183a70] B2 --> B3[No qwen4_moe factory, contiguous KV, text-only] B2 --> B4[Qwen4Tokenizer fails strict class check] B2 --> B5[Unsupported effort levels & flat 1,024 image KV] end subgraph After["After (feat/qwen4-35b-a3b-provider @ e83c8735)"] A1[qwen4-35b-a3b request] --> A2[Qualified qwen4MoE35BA3B + SDK main @ 64a6f34f] A2 --> A3[Paged KV, SSD prefix cache, embedded MTP, multi-row cohorts] A2 --> A4[Native Qwen4ChatEncoder + segment cache; compat fail-closed] A2 --> A5[Mapped efforts low/high/xhigh/off, per-image KV, 32f/4096t video] A2 --> A6[Memory-resident PLE default 39.36 GiB quote -> 64 GB floor] endCode Path
flowchart TB subgraph Config["Config & Service"] TOML["provider.toml qwen4_ngram_residency_by_model"] --> NR["Qwen4NgramResidency.apply"] ENV["Operator env / Qwen4KillSwitches.all"] --> LA["LaunchAgent.passthroughEnvironment"] end subgraph Prompt["Prompting & Tools"] REQ["OpenAIChatCompletionRequest"] --> RE["ReasoningEffort.qwen4MoELevel (516 vectors)"] REQ --> TCP["ToolChoicePromptPolicy (nativeFramingHandlesChoice)"] RE --> LTL["LocalTokenizerLoader -> Qwen4NativeChatEncoding + Qwen4SegmentTokenCache"] LTL --> ENC["SDK Qwen4ChatEncoder (or compat Jinja fallback)"] end subgraph Runtime["Media, Memory & Engine"] NR --> SCAN["ModelScanner -> Qwen4ExpMmapFootprint / LoadFootprint"] REQ --> MEDIA["ModelMediaPolicy + Qwen4ImageReservation + MediaIngest+VideoBudget"] ENC --> ENG["MultiModelBatchSchedulerEngine -> SDK 64a6f34f (Qwen4Exp + CBv2 MTP)"] MEDIA --> ENG endBefore any rollout
v2/qwen4-35b-a3b--97362e7471de/2026-12-04-r2on 64 GB+ (resident PLE) and 48 GB (SSD offload) Macs across M4 and M5 (including >=1024-chunk prefill, XNU wired-limit check, MTP concurrency/long-context, XML tools, vision/video, and Flash-Next non-regression).CI (dev)green on this PR, merge intodev, and cut signed/notarized provider releasev0.10.23intomaster.darkbloom-platformActivation PR settingqwen4MoeRegistryMinimumProviderVersion = "0.10.23"and runningscripts/provider-contracts.py snapshot.Validation
Verified on both Apple M4 Max and Apple M5 Max (128 GB, macOS 27.2.1, Xcode 27.2 / Swift 6.4.2) at head
e83c8735567f0c0de90eb7c3a2e037161b06baa5withlibs/mlx-swift-lmat64a6f34feffd1137f33eaaf56e6040bf296e8883:make docs-check(scripts/docs-check.sh+check-contribution-rules.py+ self-test)contribution-rules: 9 rule(s) OK,docs-check: 224 file(s) OK)python3 scripts/test-check-contribution-rules.py12/12OK)python3 scripts/docs-impact-check.py --base origin/dev77 changed file(s), canonical documentation coverage OK)make changelog-check8 valid fragment(s))python3 scripts/generate-reasoning-effort-vectors.py516 cases, 0 diff)python3 provider-swift/Tests/test_protocol_fixture_resources.py3/3OK)python3 scripts/test-stage-test-metallib.py&test-stage-swiftpm-resource-bundles.py12/12+5/5OK)DARKBLOOM_RELEASE_ENVIRONMENT=prod swift build --build-tests171.02sM4 Max;181.29sclean M5 Max)swift test --skip-build --no-parallel --filter 'Qwen4MoE|Qwen4CompatTokenizer|Qwen4NgramResidency|Qwen4KillSwitches|Qwen4NativeChatEncoding|Qwen4SegmentTokenCache|Qwen4ImageReservation|Qwen4SupportPolicy|Qwen4ExpMmapFootprint|Qwen4ExpLoadFootprint|Qwen4ToolChoicePromptPolicy|Qwen4NativeToolConstraint|Qwen4ReasoningEffortValidation|Qwen4ReasoningControl|Qwen4MediaPolicy'91Swift Testing tests in17suites +9XCTest tests,0failures on both)swift test --skip-build --no-parallel --filter 'LaunchAgent|ToolChoice|ToolArgumentNulls|TypelessNullToolSchemas|GemmaAutoCallCheck|ReasoningEffortValuesTests|CachePromptParityTests|HFTemplateFilters|TemplateJSONOrder|EngineV2SamplingDefaults|MTPAcceptance|ServingPerformance|SDKChipScopedDefaults|SDKOptInSpeedSwitches|StreamedToolCall|TemplateRenderCheck'349Swift Testing tests in40suites +6Swift Testing tests in1suite +14XCTest tests,0failures on both)swift test --skip-build --filter ProviderCoreFoundationTests63Swift Testing tests in8suites +116XCTest tests,0failures on both)Skipped / Ignored
make provider-test/ MiMo native weight fixture tests andlanding/desktop-appJS suites (unchanged by this PR; delegated to CI).LaunchAgent*TestswithoutDARKBLOOM_RELEASE_ENVIRONMENT=proddefaultsPackage.swiftondevtoio.darkbloom.provider.dev/darkbloom-dev; exportingDARKBLOOM_RELEASE_ENVIRONMENT=prod(matching.github/workflows/provider-tests.yml) passes all 14LaunchAgentlifecycle/removal/restart tests cleanly.Not proven
2026-12-04-r2(Phase 4 hardware qualification)..appbundle smoke test (Qwen4ExpMetalResources.validateResources()) and release pipeline (v0.10.23).Linked issue
Provenance:
Layr-Labs/d-inference#2911(not auto-closed; supersedes earlier 6-commit baseline).Test plan
make docs-check,python3 scripts/docs-impact-check.py --base origin/dev,make changelog-checkDARKBLOOM_RELEASE_ENVIRONMENT=prod swift build --build-testsand unit/coexistence test suites on Apple M4 Max and Apple M5 Max (128 GB)CI (dev)green on GitHub2026-12-04-r2Components touched
Protocol / interface changes
fixtures/prompt-contract/v1/reasoning_effort_vectors.jsonexpanded to 516 cases (qwen4_moe/qwen4_moe_text+qwen4_moe_template_model_types); matchingdarkbloom-platformonboarding & post-releaseprovider-contracts.py snapshottracked in Phase 2 / Phase 6.Documentation impact
docs/reference/qwen4-35b-a3b-support.md,docs/reference/configuration.md,docs/architecture/inference.md,docs/developer/test.md;docs-impact-check.pyOK).Changelog
changelog.d/<topic>.mdfragment(s) and ranmake changelog-check(8 valid fragment(s)).Refactor Pass
origin/qwen4-a3b/provider-integontoorigin/dev(08ef86a5cb) with zero manual conflict hacks; added 1 final SSH-signed commit (e83c873556) pinninglibs/mlx-swift-lmto landedmain64a6f34fand aligningchangelog.d/qwen4-a3b-sdk-pin.md,docs/reference/configuration.md, anddocs/reference/qwen4-35b-a3b-support.md.Reviewer Notes
e83c873556(SDKmainpin64a6f34f+ docs/changelog alignment),ToolChoicePromptPolicy.swift,LaunchAgent.swift,Qwen4NgramResidency.swift,Qwen4KillSwitches.swift, andMultiModelBatchSchedulerEngine.swift(image KV reservation).dev(#2929) andprovider-integbumpeddocs/developer/test.mdfreshness header to2026-12-04and edited disjoint sections; all 6 overlapping files merged cleanly and were verified by coexistence tests (LaunchAgent,ToolChoice,ToolArgumentNulls,TypelessNullToolSchemas,GemmaAutoCallCheck,ServingPerformance).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.